package com.kejiguan.ui.model;

import com.kejiguan.ui.util.CommonDate;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by apple on 16/4/16.
 */
public class DisplayArea {

    private String displayId;

    private String displayName;

    private List<ExhibitionNeItem> exhibitionNeItems;

    private List<ExhibitionNeItem> dcExhibitionNeItems;

    private List<ExhibitionNeItem> nomalExhibitionNeItems;

    private boolean isAllExhibitionNeItemOn=true;
    private boolean isAllExhibitionNeItemOff=true;

    public String getDisplayId() {
        return displayId;
    }

    public void setDisplayId(String displayId) {
        this.displayId = displayId;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public List<ExhibitionNeItem> getExhibitionNeItems() {
        return exhibitionNeItems;
    }

    public void setExhibitionNeItems(List<ExhibitionNeItem> exhibitionNeItems) {
        this.exhibitionNeItems = exhibitionNeItems;
    }

    public List<ExhibitionNeItem> getDcExhibitionNeItems() {
        return dcExhibitionNeItems;
    }

    public void setDcExhibitionNeItems(List<ExhibitionNeItem> dcExhibitionNeItems) {
        this.dcExhibitionNeItems = dcExhibitionNeItems;
    }

    public List<ExhibitionNeItem> getNomalExhibitionNeItems() {
        return nomalExhibitionNeItems;
    }

    public void setNomalExhibitionNeItems(List<ExhibitionNeItem> nomalExhibitionNeItems) {
        this.nomalExhibitionNeItems = nomalExhibitionNeItems;
    }

    public boolean isAllExhibitionNeItemOn() {
        return isAllExhibitionNeItemOn;
    }

    public boolean isAllExhibitionNeItemOff() {
        return isAllExhibitionNeItemOff;
    }

    private void addToDcList(ExhibitionNeItem exhibitionNeItem)
    {
        if (dcExhibitionNeItems==null)
        {
            dcExhibitionNeItems=new ArrayList<>(0);
        }

        dcExhibitionNeItems.add(exhibitionNeItem);
    }

    private void addToNomalList(ExhibitionNeItem exhibitionNeItem)
    {
        if (nomalExhibitionNeItems==null)
        {
            nomalExhibitionNeItems=new ArrayList<>(0);
        }

        nomalExhibitionNeItems.add(exhibitionNeItem);
    }
    public void initDatas()
    {
        if (CommonDate.DC_DISPLAY_IDS.contains(displayId)&&null!=exhibitionNeItems)
        {
            if (dcExhibitionNeItems!=null)
            {
                dcExhibitionNeItems.clear();
            }

            if (nomalExhibitionNeItems!=null)
            {
                nomalExhibitionNeItems.clear();
            }

            for (int i=0;i<exhibitionNeItems.size();i++)
            {
                ExhibitionNeItem exhibitionNeItem=exhibitionNeItems.get(i);

                if (CommonDate.DC_EX_IDS.contains(exhibitionNeItem.getExhibitionId()))
                {
                    addToDcList(exhibitionNeItem);
                }else
                {
                    addToNomalList(exhibitionNeItem);
                }
            }
        }


        boolean isAllOn=true;
        boolean isAllOff=true;

        for (ExhibitionNeItem exhibitionNeItem:exhibitionNeItems)
        {
            if (!CommonDate.STATE_RUNNING.equals(exhibitionNeItem.getExhibitionState()))
            {
                isAllOn=false;
                break;
            }
        }

        for (ExhibitionNeItem exhibitionNeItem:exhibitionNeItems)
        {
            if (!CommonDate.STATE_EXIT.equals(exhibitionNeItem.getExhibitionState()))
            {
                isAllOff=false;
                break;
            }
        }

        isAllExhibitionNeItemOff=isAllOff;
        isAllExhibitionNeItemOn=isAllOn;

    }
}
